#ifndef _RFCONFIG_H_
#define _RFCONFIG_H_
#include "sys.h"
#include "e22_rf_config.h"
////////////////////////////////////////////////////////////////////////////////// 

#define RF433_ADDR        (1001)
#define RF433_CHANNEL     (40)
#define RF433_NETID       E22_DEFAULT
#define RF433_UART_BPS    E22_UART_115200
#define RF433_UART_CHK    E22_UART_8N1
#define RF433_RF_BPS      E22_RF_BPS_4K8
#define RF433_RF_PACK     E22_RF_PACK_240
#define RF433_RSSI_NOISE  E22_RSSI_NOISE_OFF
#define RF433_RF_PWR      E22_RF_PWR_30DBM
#define RF433_RSSI_BYTES  E22_RSSI_BYTES_OFF
#define RF433_TRAN        E22_TRAN_DIRECT
#define RF433_TRAN_RELAY  E22_TRAN_RELAY_OFF
#define RF433_LBT         E22_LBT_OFF
#define RF433_WOR         E22_WOR_RECIVE
#define RF433_WOR_PERIOD  E22_WOR_PERIOD_2000
#define RF433_CRYPT_H     E22_DEFAULT
#define RF433_CRYPT_L     E22_DEFAULT
#define RF433_START_ADDR  (0x00)
#define RF433_PACK_LEN    (0x09)
#define RF433_CONFIG_PACK { \
						   (uint8_t)E22_CMD_HEAD, \
						   (uint8_t)RF433_START_ADDR, \
						   (uint8_t)RF433_PACK_LEN, \
						   (uint8_t)(RF433_ADDR >> 8)&0xff, \
						   (uint8_t)(RF433_ADDR)&0xff, \
						   (uint8_t)RF433_NETID, \
						   (uint8_t)((RF433_UART_BPS&0x07) << 5)|((RF433_UART_CHK&0x03) << 3)|(RF433_RF_BPS&0x07), \
						   (uint8_t)((RF433_RF_PACK&0x03) << 6)|(RF433_RSSI_NOISE << 5)|(RF433_RF_PWR&0x03), \
						   (uint8_t)RF433_CHANNEL % E22_CHANNEL_MAX, \
						   (uint8_t)(RF433_RSSI_BYTES << 7)|(RF433_TRAN << 6)|(RF433_TRAN_RELAY << 5)|(RF433_LBT << 4)|(RF433_WOR << 3)|(RF433_WOR_PERIOD&0x03), \
						   (uint8_t)RF433_CRYPT_H, \
						   (uint8_t)RF433_CRYPT_L, \
						  }

						  
#define  RF433_MD0_HIGH()	  	GPIO_SetBits(GPIOB,GPIO_Pin_14)
#define	 RF433_MD0_LOW()	    GPIO_ResetBits(GPIOB,GPIO_Pin_14)
#define  RF433_MD1_HIGH()	  	GPIO_SetBits(GPIOB,GPIO_Pin_15)
#define	 RF433_MD1_LOW()	    GPIO_ResetBits(GPIOB,GPIO_Pin_15)

#define TX_MODE 0
#define RX_MODE 1

void RF_Channel_Config(uint8_t rfmode,uint16_t addr,uint8_t channel,uint8_t power,uint8_t rate);
void RF_GPIO_Config(void);
void E22_RF_Config(uint16_t addr,uint8_t channel);
void ble_config(char blename[]);

#endif

